<?php

namespace App\Http\Controllers;

use App\Article;
use App\ArticleType;
use App\Product;
use App\ProductType;

class IndexController extends Controller
{
    public function index()
    {
        $productTypes = ProductType::orderBy('sort', 'asc')
            ->get();
        $recommendProducts = Product::where('recommend', '0') // 推荐产品
            ->get();
        $news = Article::where('type_id', '1') // 新闻动态
            ->take(5)->get();
        $companyIntroduce = ArticleType::find(2); // 公司简介
        return view('index', [
            'news' => $news,
            'productTypes' => $productTypes,
            'companyIntroduce' => $companyIntroduce,
            'recommendProducts' => $recommendProducts
        ]);
    }
}